package com.jxbeidou.system.user.convert;

import com.jxbeidou.core.entity.SecurityUserVO;
import com.jxbeidou.system.api.user.dto.UserDTO;
import com.jxbeidou.system.user.entity.UserDO;
import com.jxbeidou.system.user.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
* 登录用户表
*
* @author 杜晓祥 
* @since 1.0.0 2023-12-14
*/
@Mapper
public interface UserConvert {
    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    UserDO convert(UserVO vo);

    UserVO convert(UserDO entity);

    List<UserVO> convertList(List<UserDO> list);


    @Mappings({
        @Mapping(target = "superAdmin", expression = "java(entity.getSuperAdmin() != null && entity.getSuperAdmin() != 0)"),
        @Mapping(target = "status", expression = "java(entity.getStatus() != null && entity.getStatus() != 0)")
    })
    SecurityUserVO convertSecurity (UserDO entity);

    UserDTO convertDto (UserDO entity);

}